/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.auth.ZAuthToken;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.zimlet.ZimletUtil;
/*    */ import com.zimbra.cs.zimlet.ZimletUtil.ZimletSoapUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class UndeployZimlet
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   private static class UndeployThread
/*    */     implements Runnable
/*    */   {
/*    */     final Server server;
/*    */     String name;
/*    */     ZAuthToken auth;
/*    */     
/*    */     public UndeployThread(Server s, String na, ZAuthToken au)
/*    */     {
/* 43 */       this.server = s;
/* 44 */       this.name = na;
/* 45 */       this.auth = au;
/*    */     }
/*    */     
/*    */     public void run()
/*    */     {
/*    */       try {
/* 51 */         ZimletUtil.ZimletSoapUtil soapUtil = new ZimletUtil.ZimletSoapUtil(this.auth);
/* 52 */         soapUtil.undeployZimletRemotely(this.server, this.name);
/*    */       } catch (Exception e) {
/* 54 */         ZimbraLog.zimlet.info("undeploy", e);
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 61 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 62 */     String name = request.getAttribute("name");
/* 63 */     String action = request.getAttribute("action", null);
/* 64 */     ZAuthToken auth = null;
/* 65 */     if (action == null) {
/* 66 */       auth = zsc.getRawAuthToken();
/*    */     }
/*    */     
/* 69 */     Element response = zsc.createElement(AdminConstants.UNDEPLOY_ZIMLET_RESPONSE);
/*    */     
/* 71 */     ZimletUtil.undeployZimletLocally(name);
/* 72 */     if ("deployall".equals(action))
/*    */     {
/* 74 */       for (Server server : Provisioning.getInstance().getAllServers()) {
/* 75 */         if (!server.isLocalServer()) {
/* 76 */           checkRight(zsc, context, server, Rights.Admin.R_deployZimlet);
/* 77 */           new Thread(new UndeployThread(server, name, auth)).start();
/*    */         }
/*    */       }
/*    */     }
/*    */     
/* 82 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 87 */     relatedRights.add(Rights.Admin.R_deployZimlet);
/* 88 */     notes.add("Need the " + Rights.Admin.R_deployZimlet.getName() + " right on all servers.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/UndeployZimlet.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */